package com.company;


import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

public class Task1 {


    public static void main(String[] args) {
        //todo 1.你的上次生日过了多少天？下次生日还有多少天？
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String dbtime1 = formatter.format(new Date());  //当前时间
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入上次生日的月份");
        String str1 = scan.next(); //月份
        System.out.println("请输入上次生日的日期");
        String str2 = scan.next(); //日
        String dbtime2 = "2020-"+ str1 +"-"+ str2;  //生日
        try {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            Date date1 = format.parse(dbtime1);
            Date date2 = format.parse(dbtime2);
            int day = (int) ((date1.getTime() - date2.getTime()) / (1000*3600*24));
            System.out.println("您的生日距现在已有"+day+"天，" );
            int day2 = (int) (365 - ((date1.getTime() - date2.getTime()) / (1000*3600*24)));
            System.out.println("距下次生日还有"+day2+"天，" );
        }catch (Exception e){
            e.printStackTrace();
        }
    }

}
